<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="author" content="赵鹤阳">
    <title></title>
    <style>
    textarea{
        width: 300px;
        height: 100px;
    }
    </style>
</head>
<body>
    <textarea class="text"></textarea>
    <p>以输入 <span class="shuru"></span>字</p>
<script src="./jquery.js"></script>
</body>
</html>
<script>
    var num = 0;
    $('.text').keyup(function(){
        for (var i = 0; i < $('.text').val().length; i++) {
            if ($('.text').val().charCodeAt(i) >255) {
               num=num+1
            } else {
               num=num+0.5
            }
        }
        if (num>150) {
             $('p').replaceWith('<p>已超过限定字数</p>')
        }
        else if(num%1==0){
            $('.shuru').text(num)
        }else{
$('.shuru').text(Math.ceil(num))
        }
        num=0;
    })
</script>